<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of PostModel
 * 文章关联模型
 * @author yihua
 */

namespace Common\Model;

use Think\Model\ViewModel;

class CommentViewModel extends ViewModel {

    /**
     * 加载文章列表
     */
    protected $tableName = 'comment';
    public $viewFields = array(
        'comment' => array('*', '_type' => 'LEFT'),
        'post' => array('post_title', '_on' => 'post.post_id=comment.post_id')
    );

    /**
     * 加载列表
     */
    public function loadList($map) {
        $options = $this->options;
        $this->options = array();
        $count = $this->where($map)->count();
        $list['count'] = $count;
        $list['page'] = loadPage($count, $options['limit']);
        $this->options = $options;
        $list['list'] = $this->where($map)->select();
        return $list;
    }

}
